import request from '@/utils/request'

// 登录
export const login = (params) => {
  return request({
    method: 'post',
    url: '/system/user/login',
    params: params,
  })
}

// 退出登录
export const logout = () => {
  return request({
    method: 'post',
    url: '/system/user/logout',
  })
}

// 用户列表
export const getUserList = (params) => {
  return request({
    method: 'post',
    url: '/system/user/meta/query',
    data: params,
  })
}

// 用户新增
export const userAdd = (params) => {
  return request({
    method: 'post',
    url: `/system/user/meta/addOrUpdate`,
    data: params,
  })
}

// 重置密码
export const resetPwd = (params) => {
  return request({
    method: 'put',
    url: '/system/user/resetPwd',
    data: params,
  })
}

// 修改密码
export const changePwd = (params) => {
  return request({
    method: 'put',
    url: '/system/user/changePwd',
    data: params,
  })
}

// 用户批量修改
export const userUpdateBatch = (params) => {
  return request({
    method: 'post',
    url: `/system/user/meta/updateBatch`,
    data: params,
  })
}

// 用户详情
export const getUserDetail = (params) => {
  return request({
    method: 'get',
    url: '/system/user/meta/get',
    params: params,
  })
}

// 删除用户
export const userDelete = (params) => {
  return request({
    method: 'delete',
    url: '/system/user/meta/delete',
    params: params,
  })
}

// 部门树
export const getDeptTree = (params) => {
  return request({
    method: 'get',
    url: '/system/department/getDepartmentTree',
    params: params,
  })
}

// 获取单位
export const getUnitList = (params) => {
  return request({
    method: 'get',
    url: '/system/unit/tree',
    params: params,
  })
}

// 获取单位下部门
export const getDepartmentList = (params) => {
  return request({
    method: 'get',
    url: '/system/department/tree',
    params: params,
  })
}

// 获取单位下人员树
export const getDepartmentPersonTree = (params) => {
  return request({
    method: 'get',
    url: '/system/department/getDepartmentTree',
    params: params,
  })
}

// 用户查询列表
export const getUserByChoose = (params) => {
  return request({
    method: 'post',
    url: '/system/user/meta/query/choose',
    data: params,
  })
}
